package cn.train.service;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import cn.train.dao.IAdminGuanLi;
import cn.train.model.Admin;
import cn.train.util.SqlSessionFactoryUtil;

public class AdminServices {
	SqlSession session=SqlSessionFactoryUtil.getSqlSession();
	IAdminGuanLi admin=session.getMapper(IAdminGuanLi.class);
	
	public List<Admin> AllAdmin(int pageIndex,int pageSize){
		pageIndex=(pageIndex-1)*pageSize;
		return admin.AllAdmin( pageIndex,pageSize);
	}
	public int getCount(){
		return admin.getcount();
	}
	
	public int addAdmin(Admin adm){
		int m=admin.AddAdmin(adm);
		session.commit();
		return m;
	}
	
	public int delAdmin(int id){
		int m=admin.delAdmin(id);
		session.commit();
		return m;
	}
		public int update(int id,int state){
		int m=admin.update(id, state);
		session.commit();
		return m;
	}
	public int changeState(int id,int state){
		int m=admin.change(id, state);
		session.commit();
		return m;
	}
		
	
}
